ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
FLASH.h File Reference

Flash-related operations. More...

Go to the source code of this file.

Defines

#define TRUE   (1u)
#define CLEAR   (0u)
#define BITS_IN_NIBBLE   (4u)
#define BITS_IN_BYTE   (8u)
#define BYTES_IN_16   (2u)
#define BYTES_IN_32   (4u)
#define BITS_IN_32   (32u)
#define BITS_IN_16   (16u)
#define BIT_DEFINITION
#define BIT0   (1u << 0u)
#define BIT1   (1u << 1u)
#define BIT2   (1u << 2u)
#define BIT3   (1u << 3u)
#define BIT4   (1u << 4u)
#define BIT5   (1u << 5u)
#define BIT6   (1u << 6u)
#define BIT7   (1u << 7u)
#define BIT8   (1u << 8u)
#define BIT9   (1u << 9u)
#define BIT10   (1u << 10)
#define BIT11   (1u << 11)
#define BIT12   (1u << 12)
#define BIT13   (1u << 13)
#define BIT14   (1u << 14)
#define BIT15   (1u << 15)
#define BIT16   (1u << 16)
#define BIT17   (1u << 17)
#define BIT18   (1u << 18)
#define BIT19   (1u << 19)
#define BIT20   (1u << 20)
#define BIT21   (1u << 21)
#define BIT22   (1u << 22)
#define BIT23   (1u << 23)
#define BIT24   (1u << 24)
#define BIT25   (1u << 25)
#define BIT26   (1u << 26)
#define BIT27   (1u << 27)
#define BIT28   (1u << 28)
#define BIT29   (1u << 29)
#define BIT30   (1u << 30)
#define BIT31   (1u << 31)
#define CODE_FLASH_ARRAY_0_MIN_ADDRESS   (0x00000000u)
#define CODE_FLASH_ARRAY_0_TOP_ADDRESS   (0x0007FFFFu)
#define CODE_FLASH_ARRAY_0_SHADOW_TOP_ADDRESS   (0x0027FFFFu)
#define CODE_FLASH_ARRAY_0_SHADOW_MIN_ADDRESS   (0x00200000u)
#define DATA_FLASH_ARRAY_0_MIN_ADDRESS   (0x00800000u)
#define DATA_FLASH_ARRAY_0_TOP_ADDRESS   (0x0087FFFFu)
#define CODE_FLASH_F0_SECTOR_MIN   (0x00000000u)
#define CODE_FLASH_F0_SECTOR_MAX   (0x00007FFFu)
#define CODE_FLASH_F1_SECTOR_MIN   (0x00008000u)
#define CODE_FLASH_F1_SECTOR_MAX   (0x0000BFFFu)
#define CODE_FLASH_F2_SECTOR_MIN   (0x0000C000u)
#define CODE_FLASH_F2_SECTOR_MAX   (0x0000FFFFu)
#define CODE_FLASH_F3_SECTOR_MIN   (0x00010000u)
#define CODE_FLASH_F3_SECTOR_MAX   (0x00017FFFu)
#define CODE_FLASH_F4_SECTOR_MIN   (0x00018000u)
#define CODE_FLASH_F4_SECTOR_MAX   (0x0001FFFFu)
#define CODE_FLASH_F5_SECTOR_MIN   (0x00020000u)
#define CODE_FLASH_F5_SECTOR_MAX   (0x0003FFFFu)
#define CODE_FLASH_F6_SECTOR_MIN   (0x00040000u)
#define CODE_FLASH_F6_SECTOR_MAX   (0x0005FFFFu)
#define CODE_FLASH_F7_SECTOR_MIN   (0x00060000u)
#define CODE_FLASH_F7_SECTOR_MAX   (0x0007FFFFu)
#define DATA_FLASH_F0_SECTOR_MIN   (0x00800000u)
#define DATA_FLASH_F0_SECTOR_MAX   (0x00803FFFu)
#define DATA_FLASH_F1_SECTOR_MIN   (0x00804000u)
#define DATA_FLASH_F1_SECTOR_MAX   (0x00807FFFu)
#define DATA_FLASH_F2_SECTOR_MIN   (0x00808000u)
#define DATA_FLASH_F2_SECTOR_MAX   (0x0080BFFFu)
#define DATA_FLASH_F3_SECTOR_MIN   (0x0080C000u)
#define DATA_FLASH_F3_SECTOR_MAX   (0x0080FFFFu)
#define DATA_FLASH_SECTOR_SIZE   (0X00004000u)
#define FLASH_PRIMARY_LOCK_KEY   (0xA1A11111u)
#define FLASH_SECONDARY_LOCK_KEY   (0xC3C33333u)
#define FLASH_ALLOW_COMPLETE_REFLASH   (0x00100000u)
#define FLASHING_TIMEOUT   (0xF000u)
#define ERASING_TIMEOUT   (0x1000000u)
#define STATUS_FLASHING_TIME_OUT   (0x01u)
#define STATUS_PROGRAMMED_WRONG   (0x02u)
#define FLASH_ROUTINE_SIZE   (0xDEu)
#define ERASE_ROUTINE_SIZE   (0x7Cu)
#define RAM_ADDRESS_FOR_FLASHING_ROUTINE   (0x40000000u)
#define N_ELEMENTS(X)   (sizeof(X)/sizeof(*(X)))
#define PROGRAM
#define ERASE

Typedefs

typedef struct CFLASH_tagFlash_t

Enumerations

enum  FLASH_TYPE { NOT_FLASHABLE = 0x7Fu, CODE_FLASH, CODE_FLASH_SHADOW, DATA_FLASH }
enum  FLASH_SECTOR {
  F0 = 0, F1, F2, F3,
  F4, F5, F6, F7
}
enum  FLASH_OPERATION {
  DOUBLE_WORD_PROGRAM = 0x52u, SECTOR_ERASE, ARRAY_INTEGRITY_CHECK, MARGIN_READ,
  ECC_LOGIC_CHECK
}

Functions

uint8_t u8fnFlashWrite (uint32_t *pu32Source, uint32_t *pu32Destination, uint16_t u16Size)
 This is the public function that allows flashing of data. It will copy u8fnFlashWriteDataFromRAM to RAM and execute the complete series of steps to correctly flash.
uint8_t u8fnFlashErase (uint32_t *pu32DataToErase)
 This is the public function that allows erasure of data. It will copy u8fnFlashEraseFromRAM to RAM and execute the complete series of steps to correctly erase the sector.

Detailed Description

Flash-related operations.

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
Version:
Date:
Warning:
(If needed)

History:


Define Documentation

#define ERASE
Value:
((uint8_t(*)(Flash_t ptFlashInstance, uint32_t u32LMS))\
                  (RAM_ADDRESS_FOR_FLASHING_ROUTINE))
#define PROGRAM
Value:
((uint8_t(*)(uint32_t* pu32Addrss, uint32_t* pu32Wrd, \
                  Flash_t ptInst, uint8_t u8TwoBytsAOnc))\
                  (RAM_ADDRESS_FOR_FLASHING_ROUTINE))

Function Documentation

uint8_t u8fnFlashErase ( uint32_t *  pu32DataToErase)

This is the public function that allows erasure of data. It will copy u8fnFlashEraseFromRAM to RAM and execute the complete series of steps to correctly erase the sector.

Parameters:
pu32DataToErase,:Pointer to any address within the sector that shall be erased.
Returns:
u8Status: STATUS_FLASHING_TIME_OUT if timed-out before erasing, STATUS_PROGRAMMED_WRONG if PEG is not set to 1 after erasing, NOT_FLASHABLE if address are out of flash area.
uint8_t u8fnFlashWrite ( uint32_t *  pu32Source,
uint32_t *  pu32Destination,
uint16_t  u16Size 
)

This is the public function that allows flashing of data. It will copy u8fnFlashWriteDataFromRAM to RAM and execute the complete series of steps to correctly flash.

Parameters:
pu32Source,:Pointer to data source that must be flashed.
pu32Destination,:pointer to initial destination location.
u16Size,:Number of 32-bit words to be flashed.
Returns:
u8Status: STATUS_FLASHING_TIME_OUT if timed-out before flashing, STATUS_PROGRAMMED_WRONG if PEG is not set to 1 after flashing, NOT_FLASHABLE if addresses are out of flash area.